package com.compass.mobile.presenters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.leanback.widget.Presenter
import androidx.recyclerview.widget.RecyclerView
import com.compass.mobile.R
import com.compass.mobile.framework.ext.gone
import com.compass.mobile.framework.ext.visible
import com.compass.mobile.framework.utils.DateUtils
import com.compass.mobile.models.CaseHistory
import com.compass.mobile.models.MedicalRecordReport
import com.compass.mobile.ui.adapter.GridImageAdapter

/**
 * Description：
 * Date:2024/6/20 17:17
 */
class ReportUploadPresenter : Presenter() {

    override fun onCreateViewHolder(viewGroup: ViewGroup): ViewHolder {
        val view = LayoutInflater.from(viewGroup.context)
            .inflate(R.layout.item_report_case, viewGroup, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any) {
        if (item is MedicalRecordReport) {
            val vh = viewHolder as ViewHolder
            if (item.id.isNullOrEmpty()) {
                vh.llAdd.visible()
                vh.llInfo.gone()
            } else {
               vh.tvDiagnosis.text="病情诊断：${item.diagnosisContent}"
               vh.tvDate.text="上传日期：${DateUtils.conversionTime(item.createTime,DateUtils.FORMAT_TWO)}"
                vh.llAdd.gone()
                vh.llInfo.visible()
            }
        }
    }

    override fun onUnbindViewHolder(viewHolder: Presenter.ViewHolder) {

    }


    class ViewHolder(view: View) : Presenter.ViewHolder(view) {
        var llInfo: ConstraintLayout = view.findViewById(R.id.llInfo)
        var llAdd: LinearLayout = view.findViewById(R.id.llAdd)
        var tvDiagnosis:TextView = view.findViewById(R.id.tvDiagnosis)
        var tvDate:TextView = view.findViewById(R.id.tvDate)
    }
}